import router from "./router";

import store from "./store";

router.beforeEach((to, from, next) => {
    let token = store.state.user.token
    // console.log(token);

    if (token) {
        if (to.path == '/login') {
            next(from.path)
        } else {
            next()
        }
    } else {
        if (to.path == '/login') {
            next()
        } else {
            next('/login')
        }
    }
})